﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace ChannelVN.Cached.Entity
{
    [DataContract]
    public class CacheClientItem
    {
        [DataMember]
        public string Name { get; set; }
        [DataMember]
        public string ConfigSectionName { get; set; }
        [DataMember]
        public CacheClientSetting[] CacheClientSettings { get; set; }

        public string GetCacheClientSetting(string key)
        {
            var count = CacheClientSettings.Length;
            for (var i = 0; i < count; i++)
            {
                if (CacheClientSettings[i].Key == key)
                {
                    return CacheClientSettings[i].Value;
                }
            }
            return string.Empty;
        }

        [DataContract]
        public struct CacheClientSetting
        {
            [DataMember]
            public string Key;
            [DataMember]
            public string Value;

            public CacheClientSetting(string key, string value)
            {
                Key = key;
                Value = value;
            }
        }
    }
}
